
export default {
    methods: {
        ShowEdit () {
            this.isShowEdit = true
        },
        getPostDataList (page, pageSize) {
            return this.$http.get('/data-source/user/tableName/post').then(res => {
            // 可以在这里添加业务操作
                this.postList = res?.data?.list
                return res
            }).catch((err) => {
                console.log(err)
            })
        },
        addPostData () {
            return this.$http.post('/data-source/user/tableName/post', this.formD6549model).then(res => {
            // 可以在这里添加业务操作
                this.getPostDataList()
                this.isShowEdit = false
                return res
            }).catch((err) => {
                console.log(err)
            })
        },
        getCommentDataList (page, pageSize) {
            return this.$http.get('/data-source/user/tableName/comment').then(res => {
            // 可以在这里添加业务操作
                const pid = this.$route.query.id
                console.log(res)
                this.commentList = res?.data?.list?.filter(item => +item.postid === +pid)
                return res
            }).catch((err) => {
                console.log(err)
            })
        },
        addCommentData (data) {
            return this.$http.post('/data-source/user/tableName/comment', {
                postid: this.postId,
                content: this.commentContent
            }).then(res => {
            // 可以在这里添加业务操作
                this.getCommentDataList()
                this.commentContent = ''
                return res
            }).catch((err) => {
                console.log(err)
            })
        },
        getPostData () {
            this.$http.get(`/data-source/user/tableName/post/id/${this.$route.query.id}`).then(
                (res) => {
                    this.postTitle = res?.data?.title
                    this.postContent = res?.data?.content
                    this.postId = res?.data?.id
                }
            )
        },
        gotoDetail (id) {
            this.$router.push(
                {
                    name: 'pdetail',
                    query: {
                        id
                    }
                }
            )
        },
        getData () {
            this.getPostData()
            this.getCommentDataList()
        }
    }
}
